<template>
  <lb-layout
    v-loading="$store.getters.loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="#a19f9fb0;"
    :paddBottom="5"
  >
    <div class="head">
      <div>单位名称：{{ deptName }} {{ $route.query.day }} 月</div>
      <el-button @click="goBack" size="small" style="margin-left: 20px"
        >返回</el-button
      >
    </div>
    <el-calendar v-model="value">
      <template slot="dateCell" slot-scope="{ date, data }">
        {{ data.day }}
        <div v-for="(item, index) in list" :key="index">
          <div v-if="item.date === data.day" class="total">
            用电量：{{ item.total | numDealfilters }}
          </div>
        </div>
      </template>
    </el-calendar>
  </lb-layout>
</template>
      
      <script>
import { getDeptUsedElectricityDay } from "@/api/electricity/index.js";
import { dealElectricity } from "@/utils/index";
import {} from "@/api/park/parkmsg.js";
export default {
  name: "",
  components: {},
  dicts: [],
  data() {
    return {
      value: "",
      list: [],
      deptId: "",
      deptName: "",
    };
  },
  filters: {
    numDealfilters(num) {
      let result;
      result = num;
      let num1;
      if (typeof num == "string") {
        num1 = Number(num);
      } else {
        num1 = num;
      }
      result = dealElectricity(num1, 1, 2);
      return result + "kwh";
    },
  },
  created() {
    this.value = this.$route.query.day;
    this.deptId = this.$route.query.deptId;
    this.deptName = this.$route.query.deptName;
    this.getInfo();
  },
  methods: {
    goBack() {
      this.$router.go(-1);
    },
    getInfo() {
      const { year, month } = this.$route.query;
      getDeptUsedElectricityDay({
        deptId: this.deptId,
        year,
        month,
      })
        .then((res) => {
          if (res.code === 700) {
            this.$message.warning(res.msg);
            return false;
          }
          this.list = res?.data || [];
        })
        .catch((err) => {
          // this.$message.error("系统错误,请联系管理员!3001007");
        });
    },
  },
};
</script>
      
      <style lang="scss" scoped>
::v-deep .el-calendar-table:not(.is-range) td.next {
  display: none;
}
::v-deep .el-calendar-table:not(.is-range) td.prev {
  visibility: hidden;
}
::v-deep .el-calendar__button-group {
  display: none;
}
// ::v-deep .el-calendar-table td {
//   border: 1px solid #ebeef5;
// }
::v-deep .el-calendar__header {
  display: none;
}
::v-deep .el-calendar__body {
  thead th:not(.is-hidden):last-child {
    border-left: none;
  }
}
.total {
  margin-top: 10px;
  color: #666666;
}
.head {
  font-size: 28px;
  font-weight: 400;
  display: flex;
  align-items: center;
}
</style>
      